<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ include file="../../../attr.jsp" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<!doctype html>
<html>
<head>
<meta http-equiv="X-UA-Compatible" content="IE=emulateIE7" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta charset="utf-8">
<link rel="stylesheet" href="${ctx}/css/sapar.css" />
<link rel="stylesheet" type="text/css" href="${ctx}/css/common.css" />
<script type="text/javascript" src="${ctx}/js/jquery.js"></script>
<script type="text/javascript" src="${ctx}/js/sapar.js"></script>
<script type="text/javascript" src="${ctx}/js/WdatePicker.js"></script>
<script type="text/javascript" src="${ctx}/assets/layer/layer.js"></script>
<title>科室编辑管理</title>
<style type="text/css">
.kv-item label{
	width: 120px;
}
</style>
</head>

<body>
    <div id="saper-container">
        <div id="saper-hd"></div>
        <div id="saper-bd">
            <div class="subfiled clearfix">
                <h2>科室编辑管理</h2>
            </div>
			<div class="subfiled-content">
	            <form class="saper-form" id="dataForm">
	                <div class="kv-item clearfix">
	                    <label><span class="impInfo">*</span>科室名称：</label>
	                    <div class="kv-item-content">
	                    	<input name="departmentName" id="departmentName" class="txt_required" placeholder="此项为必填项目！" type="text" value="${department.departmentName}" onkeyup="this.value=this.value.replace(/(^\s*)|(\s*$)/g,'')">
	                    </div>
	                </div>
	                <%--<div class="kv-item clearfix">--%>
	                    <%--<label><span class="impInfo">*</span>科室助记码：</label>--%>
	                    <%--<div class="kv-item-content">--%>
	                    	<%--<input name="departmentCode" id="departmentCode" class="txt_required" placeholder="科室助记码" type="text" value="${department.departmentCode}" readonly="readonly" >--%>
	                    <%--</div>--%>
	                <%--</div>--%>
					<div class="kv-item clearfix">
						<label><span class="impInfo">*</span>科室负责人：</label>
						<div class="kv-item-content">
							<input name="departmentMan" id="departmentMan" class="txt_required" placeholder="科室负责人" type="text" value="${department.departmentMan}" onkeyup="this.value=this.value.replace(/(^\s*)|(\s*$)/g,'')">
						</div>
					</div>
					
					<div class="kv-item clearfix">
						<label>科室电话：</label>
						<div class="kv-item-content">
							<input name="departmentTel" id="departmentTel" class="txt_required" placeholder="科室电话" type="text" value="${department.departmentTel}" onkeyup="this.value=this.value.replace(/\D/g,'')">
						</div>
					</div>
					
					<div class="kv-item clearfix">
						<label>是否厂家：</label>
						<div class="kv-item-content">
							<select class="empty" id="departmentIsclean" name="departmentIsclean">
								<option value="0" <c:if test="${department.departmentIsclean==1}">selected="true" </c:if> >否</option>
								<option value="1" <c:if test="${department.departmentIsclean==0}">selected="true" </c:if> >是</option>
							</select>
						</div>
					</div>
					
					<%--<div class="kv-item clearfix">--%>
						<%--<label>是否启用：</label>--%>
						<%--<div class="kv-item-content">--%>
							<%--<select class="empty" id="departmentIshide" name="departmentIshide">--%>
								<%--<option value="1" <c:if test="${department.departmentIshide==1}">selected="true" </c:if> >启用</option>--%>
								<%--<option value="0" <c:if test="${department.departmentIshide==0}">selected="true" </c:if> >不启用</option>--%>
							<%--</select>--%>
						<%--</div>--%>
					<%--</div>--%>

					<div class="kv-item clearfix">
						<label>栋数：</label>
						<div class="kv-item-content">
							<select class="empty" id="departmentDong" name="departmentDong">
								<option value="1" <c:if test="${department.departmentDong==1}">selected="true" </c:if> >1栋</option>
								<option value="2" <c:if test="${department.departmentDong==2}">selected="true" </c:if> >2栋</option>
								<option value="3" <c:if test="${department.departmentDong==3}">selected="true" </c:if> >3栋</option>
								<option value="4" <c:if test="${department.departmentDong==4}">selected="true" </c:if> >4栋</option>
								<option value="5" <c:if test="${department.departmentDong==5}">selected="true" </c:if> >5栋</option>
								<option value="6" <c:if test="${department.departmentDong==6}">selected="true" </c:if> >6栋</option>
								<option value="7" <c:if test="${department.departmentDong==7}">selected="true" </c:if> >7栋</option>
							</select>
						</div>
					</div>

					<div class="kv-item clearfix">
						<label>层数：</label>
						<div class="kv-item-content">
							<select class="empty" id="departmentCeng" name="departmentCeng">
								<option value="1" <c:if test="${department.departmentCeng==1}">selected="true" </c:if> >1层</option>
								<option value="2" <c:if test="${department.departmentCeng==2}">selected="true" </c:if> >2层</option>
								<option value="3" <c:if test="${department.departmentCeng==3}">selected="true" </c:if> >3层</option>
								<option value="4" <c:if test="${department.departmentCeng==4}">selected="true" </c:if> >4层</option>
								<option value="5" <c:if test="${department.departmentCeng==5}">selected="true" </c:if> >5层</option>
								<option value="6" <c:if test="${department.departmentCeng==6}">selected="true" </c:if> >6层</option>
								<option value="7" <c:if test="${department.departmentCeng==7}">selected="true" </c:if> >7层</option>
								<option value="8" <c:if test="${department.departmentCeng==8}">selected="true" </c:if> >8层</option>
								<option value="9" <c:if test="${department.departmentCeng==9}">selected="true" </c:if> >9层</option>
								<option value="10" <c:if test="${department.departmentCeng==10}">selected="true" </c:if> >10层</option>
								<option value="11" <c:if test="${department.departmentCeng==11}">selected="true" </c:if> >11层</option>
								<option value="12" <c:if test="${department.departmentCeng==12}">selected="true" </c:if> >12层</option>
								<option value="13" <c:if test="${department.departmentCeng==13}">selected="true" </c:if> >13层</option>
								<option value="14" <c:if test="${department.departmentCeng==14}">selected="true" </c:if> >14层</option>
								<option value="15" <c:if test="${department.departmentCeng==15}">selected="true" </c:if> >15层</option>
								<option value="16" <c:if test="${department.departmentCeng==16}">selected="true" </c:if> >16层</option>
								<option value="17" <c:if test="${department.departmentCeng==17}">selected="true" </c:if> >17层</option>
								<option value="18" <c:if test="${department.departmentCeng==18}">selected="true" </c:if> >18层</option>
								<option value="19" <c:if test="${department.departmentCeng==19}">selected="true" </c:if> >19层</option>
								<option value="20" <c:if test="${department.departmentCeng==20}">selected="true" </c:if> >20层</option>
								<option value="21" <c:if test="${department.departmentCeng==21}">selected="true" </c:if> >21层</option>
								<option value="22" <c:if test="${department.departmentCeng==22}">selected="true" </c:if> >22层</option>
								<option value="23" <c:if test="${department.departmentCeng==23}">selected="true" </c:if> >23层</option>
								<option value="24" <c:if test="${department.departmentCeng==24}">selected="true" </c:if> >24层</option>
								<option value="25" <c:if test="${department.departmentCeng==25}">selected="true" </c:if> >25层</option>
								<option value="26" <c:if test="${department.departmentCeng==26}">selected="true" </c:if> >26层</option>
								<option value="27" <c:if test="${department.departmentCeng==27}">selected="true" </c:if> >27层</option>
								<option value="28" <c:if test="${department.departmentCeng==28}">selected="true" </c:if> >28层</option>
								<option value="29" <c:if test="${department.departmentCeng==29}">selected="true" </c:if> >29层</option>
								<option value="30" <c:if test="${department.departmentCeng==30}">selected="true" </c:if> >30层</option>
							</select>
						</div>
					</div>

					<div class="kv-item clearfix">
						<label>配送区：</label>
						<div class="kv-item-content">
							<select name="departmentSendId" id="departmentSendId">
								<option value="">请选择</option>
								<c:if test="${sendImList != null}">
									<c:forEach items="${sendImList}" var="sendIm">
										<option value="${sendIm.sendId}"
												<c:if test="${department.departmentSendId==sendIm.sendId}">selected</c:if>>${sendIm.sendName}</option>
									</c:forEach>
								</c:if>
							</select>
						</div>
					</div>
					
					<div class="kv-item clearfix">
						<label>科室简介：</label>
						<div class="kv-item-content">
							<input name="departmentMark" id="departmentMark" class="txt_required" placeholder="科室简介" type="text" value="${department.departmentMark}"> 
						</div>
					</div>
					
					
	                <div class="buttons">
	                    <a href="javascript:;" class="sapar-btn sapar-btn-recom">确定</a>
	                     <input type="hidden" name="departmentNo" id="departmentNo"value="${department.departmentNo}" />
				  		 <input type="hidden" name="departmentId" id="departmentId" value="${department.departmentId}"/>
	                </div>
	            </form>
            </div>
        </div>
        <div id="saper-ft"></div>
    </div>
    
</body>

<script type="text/javascript">
function isNullOrEmpty(strVal){
	strVal = strVal.replace(/(^\s*)|(\s*$)/g,"");
	if(strVal == '' || strVal == null || strVal == undefined){
		return true;
	}else{
		return false;
	}
}
$(function(){
	$(".sapar-btn-recom").click(function(){
		 var btn = true;
		 var departmentName = $("#departmentName").val();
		 debugger
		 if(isNullOrEmpty(departmentName)){
             btn = false;
             alert("科室名不能为空")
		 }
		 if(btn){
			 $.ajax({
	             type: "POST",
	             url:"${ctx}/department/departmentSave.do",
	             data:$('#dataForm').serialize(),// 你的formid
	             error: function(request) {
	            	 	layer.alert("网络故障，请稍后再试!");
	             },
	             success: function(data) {
	 	           	if(data.status=="true"){
		 	           	layer.alert("保存成功", function(){
		 	           		window.location.href="${ctx}/department/departmentList.do";
	           		    });
	 	           	}else{
	 	           		 layer.msg(data.msg);
	 	           	}
	             }
	         }); 
		 }
	});
	 
   
   $('#departmentName').change(function(){
		var departmentName = $('#departmentName').val();
		/*速记码生成器  */
		$.ajax({
			url:"${ctx}/eng/cn2en.do?msg="+departmentName,
			dateType:"json",	
			success:function(data){
				if(data.status == "true"){
					 $("#departmentCode").val(data.msg);
				}else{
					 layer.msg("速记码转换异常");
				}
			}
		});
	});
});
</script>
</html>